#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> trainingPlan(vector<int>& actions) {
        if (actions.size() == 0)
            return actions;

        int j = 0;
        for (int i = 0; i < actions.size() - 1; ++i)
        {
            if (actions[i] % 2 == 0)
            {
                j = j > i ? j : i + 1;
                for (; j < actions.size(); ++j)
                {
                    if (actions[j] % 2)
                    {
                        swap(actions[i], actions[j]);
                        break;
                    }
                }

                if (j == actions.size())
                {
                    break;
                }
            }
        }

        return actions;
    }
};